package com.test40_JDBC;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * JDBC连接
 */
public class Demo01_Connection {
    public static final String DRIVER = "com.mysql.cj.jdbc.Driver";  // 数据库驱动程序
    public static final String URL = "jdbc:mysql://localhost:3306/yootk";   // 连接地址
    public static final String USERNAME = "root";   // 用户名
    public static final String PASSWORD = "root520";    // 密码

    public static void main(String[] args) throws Exception {
        Class.forName(DRIVER);  // 加载驱动
        Connection conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);  // 获取数据库连接
        System.out.println(conn);
        conn.close();   // 一定要关闭
    }
}
